package com.hzmall.util;

import com.hzmall.common.ResponseCode;

import java.io.Serializable;

public class ServerResponseTest<T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;

    public ServerResponseTest(Integer code) {
        this.code = code;
    }

    public ServerResponseTest(String msg) {
        this.msg = msg;
    }

    public ServerResponseTest(T data) {
        this.data = data;
    }

    public ServerResponseTest(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ServerResponseTest(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public ServerResponseTest(String msg, T data) {
        this.msg = msg;
        this.data = data;
    }

    public ServerResponseTest(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }
    public boolean isSuccess(){
        return this.code == ResponseCode.SUCCESS.getCode();
    }
    public static <T> ServerResponseTest<T> createBySuccess(){
        return new ServerResponseTest<T>(ResponseCode.SUCCESS.getCode(),ResponseCode.SUCCESS.getDesc());
    }
}
